var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, a) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var a in e)
              Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
          })(e, a);
      };
      return function (e, a) {
        function l() {
          this.constructor = e;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        t(e, a),
          (e.prototype =
            null === a
              ? Object.create(a)
              : ((l.prototype = a.prototype), new l()));
      };
    })(),
  DPPawnSaleDialog = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.canToggle = !0),
        e.tab_pawn_sale.on(Laya.Event.CLICK, e, e.onTabPawnSaleClick),
        e.btn_pawn_want.on(Laya.Event.CLICK, e, e.onPawnWantToClick),
        e.btn_sale_back.on(Laya.Event.CLICK, e, e.onPawnBackToClick),
        (e.list_pawn_fujiang.vScrollBarSkin = ""),
        (e.list_pawn_fujiang.selectEnable = !0),
        e.list_pawn_fujiang.on(Laya.Event.CLICK, e, e.onListPawnFuJiangClick),
        (e.list_pawn_wupin.vScrollBarSkin = ""),
        WebSocketService.addListener({
          caller: e,
          code: 5318,
          method: e.onLoadPawnListData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 5316,
          method: e.onLoadPawnResultData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 10090,
          method: e.onLoadFuJiangPawnListData,
        }),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showPawnSaleView = function (t) {
        return (
          null == this.pawnSaleDia &&
            ((this.pawnSaleDia = new e()), (this.pawnSaleDia.zOrder = 1e3)),
          (this.pawnSaleDia.itemObj = t),
          (this.pawnSaleDia.canToggle = !1),
          (this.pawnSaleDia.btn_sale_back.visible = !1),
          this.pawnSaleDia.popup(!0),
          this.pawnSaleDia.initView(),
          this.pawnSaleDia
        );
      }),
      (e.prototype.initView = function () {
        0 == this.itemObj.purpose
          ? (this.btn_pawn_want.label = "我想要")
          : (this.btn_pawn_want.label = "取消购买意愿"),
          (this.tab_pawn_sale.selectedIndex = 0),
          (this.lastTabSelectedIndex = 0),
          this.selectPanelUI(0);
      }),
      (e.prototype.selectPanelUI = function (t) {
        (this.panel_pawn_zhujiang.visible = !1),
          (this.panel_pawn_zhujiang.visible = 0 == t),
          (this.pannel_pawn_fujiang.visible = 1 == t),
          (this.panel_pawn_zuoji.visible = 2 == t),
          (this.panel_pawn_wupin.visible = 3 == t),
          (this.lastTabSelectedIndex = t),
          this.reqPanelListData(t + 1);
      }),
      (e.prototype.reqPanelListData = function (t) {
        WebSocketService.send({
          c: 5318,
          d: { tradeRoleId: this.itemObj.roleId, type: t },
        });
      }),
      (e.prototype.onTabPawnSaleClick = function (t) {
        if (!this.canToggle)
          return (
            ToastView.toastView("亲！请不要点这么快！我差点跟上了"),
            void (this.tab_pawn_sale.selectedIndex = this.lastTabSelectedIndex)
          );
        this.canToggle = !1;
        var e = t.target.name;
        "item0" == e
          ? this.selectPanelUI(0)
          : "item1" == e
          ? this.selectPanelUI(1)
          : "item2" == e
          ? this.selectPanelUI(2)
          : "item3" == e && this.selectPanelUI(3);
      }),
      (e.prototype.onLoadPawnListData = function (t) {
        this.canToggle = !0;
        var e = this.tab_pawn_sale.selectedIndex;
        if (0 == t.code) {
          var a;
          if (t.data) a = t.data;
          else {
            if (!t.list) return;
            a = t.data;
          }
          if (0 == e)
            (this.btn_pawn_want.visible = !0),
              this.setupZhuJiangViewFromData(a, !1);
          else if (1 == e) this.setupFuJiangViewFromData(a);
          else if (2 == e) {
            this.ThreeData = a;
            for (var l = [], i = a, n = void 0, s = 0; s < i.length; s++)
              (n = {
                item_zj_name: {
                  text:
                    i[s].name + " " + i[s].lvl + "级     经验值:" + i[s].exp,
                },
                id: i[s].id,
              }),
                l.push(n);
            this.list_pawn_zuoji.array = l;
          } else if (3 == e) {
            this.FourData = a;
            for (
              var l = [], _ = t.list, o = t.more, n = void 0, s = 0;
              s < _.length;
              s++
            )
              (n = {
                item_wp_name: {
                  text: s + 1 + "、" + _[s].name + _[s].num + "个",
                },
                id: _[s].id,
              }),
                l.push(n);
            for (s = 0; s < o.length; s++)
              (n = {
                item_wp_name: {
                  text: _.length + s + 1 + "、" + o[s].name + o[s].num + "个",
                },
                id: o[s].id,
              }),
                l.push(n);
            this.list_pawn_wupin.array = l;
          }
        } else ToastView.toastView(t.msg);
      }),
      (e.prototype.resetKangXingViewFromData = function () {
        (this.label_fuzhong_title.text = "负重："),
          (this.label_fuzhong.text = ""),
          (this.label_kangduwu_title.text = ""),
          (this.label_kangduwu.text = ""),
          (this.label_kangwu_title.text = "抗物："),
          (this.label_kangxuan_title.text = "抗玄："),
          (this.label_fengzhu_title.text = "抗封："),
          (this.label_kangluan_title.text = "抗乱："),
          (this.label_kangwei_title.text = "抗围："),
          (this.label_kangraoluan_title.text = ""),
          (this.label_kangraoluan.text = ""),
          (this.label_kangyaohuo_title.text = ""),
          (this.label_kangyaohuo.text = ""),
          (this.label_kangluolei_title.text = ""),
          (this.label_kangluolei.text = ""),
          (this.label_kanglei_title.text = "抗雷："),
          (this.label_fengli_title.text = "抗风："),
          (this.label_kanghuo_title.text = "抗火："),
          (this.label_kangdu_title.text = "抗毒："),
          (this.label_kangfengsuo_title.text = ""),
          (this.label_kangfengsuo.text = ""),
          (this.label_kangweikun_title.text = ""),
          (this.label_kangweikun.text = "");
      }),
      (e.prototype.setupZhuJiangViewFromData = function (t, e, a) {
        (this.OneData = t),
          this.resetKangXingViewFromData(),
          e
            ? ((this.label_zhujiang_roleName.text = t.name),
              (this.label_zhujiang_roleType.text = Utils.dealRole_Type(
                t.roleType
              )),
              (this.label_qixue.text = t.hp),
              (this.label_gongjili.text = t.app),
              (this.label_sudu.text = t.sp),
              (this.label_fuzhong.text = t.weight ? t.weight : "0"),
              (this.label_jingli.text = t.mp),
              (this.label_fangyuli.text = t.df),
              a &&
                ((this.label_kangwu_title.text = "命中率："),
                (this.label_kang_wu.text = a.mzl ? a.mzl : "0"),
                (this.label_kangxuan_title.text = "反击率："),
                (this.label_kang_xuan.text = a.fzl ? a.fzl : "0"),
                (this.label_fengzhu_title.text = "法术暴："),
                (this.label_kang_feng.text = a.fsbjl ? a.fsbjl : "0"),
                (this.label_kangluan_title.text = "躲避率："),
                (this.label_kang_luan.text = a.kfjn ? a.kfjn : "0"),
                (this.label_kangwei_title.text = "抗玄击："),
                (this.label_kang_wei.text = a.kxhp ? a.kxhp : "0"),
                (this.label_kangraoluan_title.text = "抗扰乱："),
                (this.label_kangraoluan.text = a.krl ? a.krl : "0"),
                (this.label_fuzhong_title.text = "抗风沙："),
                (this.label_fuzhong.text = a.kfs ? a.kfs : "0"),
                (this.label_kangduwu_title.text = "抗毒物："),
                (this.label_kangduwu.text = a.kd ? a.kd : "0"),
                (this.label_kanglei_title.text = "暴击率："),
                (this.label_kang_lei.text = a.wlbjl ? a.wlbjl : "0"),
                (this.label_fengli_title.text = "致命率："),
                (this.label_kang_fengli.text = a.zml ? a.zml : "0"),
                (this.label_kanghuo_title.text = "反震率："),
                (this.label_kang_huo.text = a.fzl ? a.fzl : "0"),
                (this.label_kangdu_title.text = "抗物理："),
                (this.label_kang_du.text = a.kwldj ? a.kwldj : "0"),
                (this.label_kangfengsuo_title.text = "抗封锁："),
                (this.label_kangfengsuo.text = a.kfs ? a.kfs : "0"),
                (this.label_kangweikun_title.text = "抗围困："),
                (this.label_kangweikun.text = a.kwk ? a.kwk : "0"),
                (this.label_kangyaohuo_title.text = "抗妖火："),
                (this.label_kangyaohuo.text = a.kyh ? a.kyh : "0"),
                (this.label_kangluolei_title.text = "抗落雷："),
                (this.label_kangluolei.text = a.kll ? a.kll : "0")))
            : ((this.label_zhujiang_roleName.text = t.roleName),
              (this.label_zhujiang_roleType.text = t.roleType),
              (this.label_qixue.text = t.hp),
              (this.label_gongjili.text = t.ap),
              (this.label_sudu.text = t.sp),
              (this.label_fuzhong.text = t.weight ? t.weight : "0"),
              (this.label_jingli.text = t.mp),
              (this.label_fangyuli.text = t.df),
              (this.label_kang_wu.text = t.k_wl ? t.k_wl : "0"),
              (this.label_kang_xuan.text = t.k_xi ? t.k_xi : "0"),
              (this.label_kang_feng.text = t.k_fa ? t.k_fa : "0"),
              (this.label_kang_luan.text = t.k_luan ? t.k_luan : "0"),
              (this.label_kang_wei.text = t.k_wei ? t.k_wei : "0"),
              (this.label_kang_lei.text = t.k_ll ? t.k_ll : "0"),
              (this.label_kang_fengli.text = t.k_feng ? t.k_feng : "0"),
              (this.label_kang_huo.text = t.k_yao ? t.k_yao : "0"),
              (this.label_kang_du.text = t.k_du ? t.k_du : "0"));
        var l;
        (l = e ? t.skillList : t.list),
          (this.label_skill_1.text = ""),
          (this.label_skill_2.text = ""),
          (this.label_skill_3.text = "");
        for (var i = 0; i < l.length; i++) {
          var n = l[i];
          0 == i
            ? (this.label_skill_1.text = n.name + this.dealGradeOrHuaString(n))
            : 1 == i
            ? (this.label_skill_2.text = n.name + this.dealGradeOrHuaString(n))
            : 2 == i &&
              (this.label_skill_2.text = n.name + this.dealGradeOrHuaString(n));
        }
      }),
      (e.prototype.dealGradeOrHuaString = function (t) {
        return t.hua >= 1
          ? "  化境Lv" + t.grade + "(" + t.useCount + "熟)"
          : "  " + t.grade + "级(" + t.useCount + "熟)";
      }),
      (e.prototype.setupFuJiangViewFromData = function (t) {
        this.TwoData = t;
        for (var e, a = [], l = t, i = 0; i < l.length; i++)
          (e = {
            item_fj_name: { text: l[i].name },
            item_fj_btn: { text: l[i].lvl },
            cortegeId: l[i].cortegeId,
            lvl: l[i].lvl,
            name: l[i].name,
            roleId: l[i].roleId,
          }),
            a.push(e);
        this.list_pawn_fujiang.array = a;
      }),
      (e.prototype.onListPawnFuJiangClick = function (t) {
        if ("" != t.target.name && "item_fj_btn" == t.target.name) {
          var e = this.list_pawn_fujiang.selectedItem;
          WebSocketService.send({
            c: 10090,
            d: { roleId: this.itemObj.roleId, cortegeId: e.cortegeId },
          });
        }
      }),
      (e.prototype.onLoadFuJiangPawnListData = function (t) {
        this.canToggle = !0;
        this.tab_pawn_sale.selectedIndex;
        0 == t.code
          ? ((this.panel_pawn_zhujiang.visible = !0),
            (this.pannel_pawn_fujiang.visible = !1),
            (this.btn_pawn_want.visible = !1),
            (this.btn_sale_back.visible = !0),
            this.setupZhuJiangViewFromData(t.data, !0, t.more))
          : ToastView.toastView(t.msg);
      }),
      (e.prototype.onLoadPawnResultData = function (t) {
        WebSocketService.send({ c: 5315, d: { roleId: Global.roleId } }),
          ToastView.toastView(t.msg),
          0 == this.itemObj.purpose
            ? (this.btn_pawn_want.label = "取消购买意愿")
            : (this.btn_pawn_want.label = "我想要");
      }),
      (e.prototype.onPawnWantToClick = function (t) {
        0 == this.itemObj.purpose
          ? WebSocketService.send({
              c: 5316,
              d: {
                tradeRoleId: this.itemObj.roleId,
                buyRoleId: Global.roleId,
                type: 1,
              },
            })
          : 1 == this.itemObj.purpose &&
            WebSocketService.send({
              c: 5316,
              d: {
                tradeRoleId: this.itemObj.roleId,
                buyRoleId: Global.roleId,
                type: 2,
              },
            });
      }),
      (e.prototype.onPawnBackToClick = function () {
        (this.panel_pawn_zhujiang.visible = !1),
          (this.pannel_pawn_fujiang.visible = !0),
          (this.btn_pawn_want.visible = !0),
          (this.btn_sale_back.visible = !1);
      }),
      e
    );
  })(ui.MarketController.DPPawnSaleDialogUI);
